package com.loan.controller.app.data;

import com.loan.common.core.controller.BaseController;
import com.loan.common.core.domain.PageQuery;
import com.loan.common.core.domain.Result;
import com.loan.common.core.page.TableDataInfo;
import com.loan.system.domain.IncomeExpendDetailEntity;
import com.loan.system.service.IncomeExpendDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Validated
@Api(value = "收支统计报表", tags = {"收支统计报表"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/app/incomeExpend")
public class IncomeExpendController extends BaseController {

    private final IncomeExpendDetailService incomeExpendDetailService;

    /**
     * 获取列表
     */
    @ApiOperation("获取列表（分页）")
    @GetMapping("/page")
    public TableDataInfo<Map<String, Object>> list(String channel, Long companyId, String beginTime, String endTime, PageQuery pageQuery) {
        return incomeExpendDetailService.selectPageList(channel, companyId, beginTime, endTime, pageQuery);
    }

    @ApiOperation("获取合计")
    @GetMapping("/total")
    public Result<List<Map<String, Object>>> total(String channel, Long companyId, String beginTime, String endTime) {
        return Result.ok(incomeExpendDetailService.selectTotal(channel, companyId, beginTime, endTime));
    }

}
